﻿using System;
using System.ServiceModel;

namespace WP7AccelerometerService
{
    class Program
    {
        private static WP7AccelerometerService _wp7AccelerometerService;

        static void Main(string[] args)
        {
            try
            {
                // setup the WP7 accelerometer service 
                _wp7AccelerometerService = new WP7AccelerometerService();
                ServiceHost serviceHost = new ServiceHost(_wp7AccelerometerService, new Uri("http://localhost:8192/"));
                serviceHost.AddServiceEndpoint(typeof(IWP7AccelerometerService), new BasicHttpBinding(BasicHttpSecurityMode.None), "WP7AccelerometerService");
                serviceHost.Open();

                Console.WriteLine("WP7 Accelerometer Service opened!");
                Console.WriteLine("Now run the WP7 Accelerometer Client on the phone.");
                Console.WriteLine("Press any key to end the service.");
            }
            catch (Exception e)
            {
                Console.WriteLine("Failed to start WP7 accelerometer service.\nMake sure the application has Administrator privilages.\n\nError details {0}", e.Message);
            }
            Console.ReadKey();
        }
    }
}
